import { createHtmlPlugin } from 'vite-plugin-html'
import { loadEnv } from 'vite'
import { ENVPREFIX } from '../.vite-vue/config/vite.base.config.ts'

// https://github.com/vbenjs/vite-plugin-html
export default function htmlPlugin(isBuild: boolean) {
  const env = loadEnv(process.env.NODE_ENV ?? 'production', process.cwd(), ENVPREFIX)
  return createHtmlPlugin({
    minify: isBuild,
    inject: {
      data: {
        title: env.VITE_APP_TITLE,
        keywords: env.VITE_APP_KEYWORDS,
        description: env.VITE_APP_DESCRIPTION,
      },
    },
  })
}
